//
//  UIBarBtnItem+Extension.swift
//  MicroBlog
//
//  Created by Jokin on 2017/3/27.
//  Copyright © 2017年 jokin. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(title: String, imageName: String?, target: Any?, action: Selector) {
        self.init()
        let button = UIButton()
        if let image = imageName{
            button.setImage(UIImage(named: image), for: .normal)
        }
        button.addTarget(target, action: action, for: .touchUpInside)
        button.setTitle(title, for: .normal)
        button.setTitleColor(UIColor.gray, for: .normal)
        button.setTitleColor(UIColor.orange, for: .highlighted)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        button.sizeToFit()
        self.customView = button
    }
    
    
}

